<template>

      <el-form ref="ruleForm" :model="ruleForm" :rules="rules" class="demo-ruleForm">
        <!-- 用户名 -->
        <el-form-item label="请输入要查找人的学号" prop="id">
          <el-input v-model="ruleForm.id" prefix-icon="el-icon-user"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="chaxun('ruleForm')">查询</el-button>
        </el-form-item>
      </el-form>
</template>

<script>
export default {
  name: 'login',
  data() {
    return{
      ruleForm:{
        id: "",
      },
      rules:{
        //验证用户名是否合法
        id:[
          { required: true, message: '请输入用户名', trigger: 'blur' }
        ]
      },
    };
  },
  methods:{
    chaxun(formName){
          this.$refs[formName].validate((valid) => {
            if (valid) {
          axios.get('http://localhost:8181/book/findById/'+this.ruleForm.id);
          console.log(this.ruleForm.id)
              this.$router.push({
                path: '/selectOne',
                query:{
                  id:this.ruleForm.id
                }
              })
        }else{
          return;
        }
      });
    },
  }

};
</script>


